home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / wnos / wn941101 / scc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-10  |  6.3 KB  |  156 lines

  1. /* Definitions for Z8530 SCC driver by PE1CHL
  2.  * Adapted for NOS 1/23/90
  3.  * Ken Mitchum KY3B
  4.  * km@speedy.cs.pitt.edu
  5.  * km@cadre.dsl.pitt.edu
  6.  */
  7. #ifndef _SCC_H
  8. #define _SCC_H
  9.  
  10. #ifndef _GLOBAL_H
  11. #include "global.h"
  12. #endif
  13.  
  14. #ifndef _8250_H
  15. #include "8250.h"
  16. #endif
  17.  
  18. #define INLINE 1
  19.  
  20. typedef int16 ioaddr;            /* type definition for an 'io port address' */
  21. #define MAXSCC        4            /* maximal number of SCC chips supported */
  22.  
  23. # if defined(INLINE)
  24. /* special delay construction only necessary when inline IN/OUT is used */
  25. #define D(v) scc_delay(v)                /* delay for 5 PCLK cycles (or more) */
  26. #define RDREG(a) (D(inportb(a)))        /* read any input port */
  27. #define WRREG(a,v) {outportb(a,v); D(1);}    /* write any output port */
  28. #define RDSCC(c,r) (outportb(c,r), D(1), D(inportb(c))) /* read SCC reg */
  29. #define WRSCC(c,r,v) {outportb(c,r); D(1); outportb(c,v); D(1);} /* write SCC reg*/
  30. # else
  31. #define RDREG(a) (inportb(a))            /* read any input port */
  32. #define WRREG(a,v) {outportb(a,v);}        /* write any output port */
  33. #define RDSCC(c,r) (outportb(c,r), inportb(c)) /* read SCC reg */
  34. #define WRSCC(c,r,v) {outportb(c,r); outportb(c,v);} /* write SCC reg */
  35. # endif
  36.  
  37. #define HWEAGLE        0x01    /* hardware type for EAGLE card */
  38. #define HWPC100        0x02    /* hardware type for PC100 card */
  39. #define HWPRIMUS    0x04    /* hardware type for PRIMUS-PC (DG9BL) card */
  40. #define HWDRSI        0x08    /* hardware type for DRSI PC*Packet card */
  41.  
  42. #ifndef VOID
  43. #define VOID(x)        (x)        /* not necessary for most compilers */
  44. #endif
  45.  
  46. struct sccinfo {
  47.     int init;                /* SCC driver initialized? */
  48.     int nchips;                /* Number of SCC chips in system */
  49.     int maxchan;            /* Highest valid channel number */
  50.     ioaddr iobase;            /* Base address of first SCC */
  51.     int space;                /* Spacing between subsequent SCCs */
  52.     int off[2];                /* Offset to A and B channel control regs */
  53.     int doff;                /* Offset from control to data register */
  54.     int ivec;                /* System interrupt vector number */
  55.     long clk;                /* PCLK/RTxC frequency in Hz */
  56.     int pclk;                /* flag to use PCLK (instead of RTxC) */
  57.     int hwtype;                /* special hardware type indicator */
  58.     int hwparam;            /* special hardware parameter */
  59. };
  60. extern struct sccinfo sccinfo;
  61.  
  62. /* SCC channel control structure for AX.25 mode */
  63. struct scca {
  64.     int32 maxdefer;            /* Timer for CSMA defer time limit */
  65.  
  66.     unsigned int tstate;    /* Transmitter state */
  67. #define IDLE        0        /* Transmitter off, no data pending */
  68. #define DEFER        1        /* Receive Active - DEFER Transmit */
  69. #define KEYUP        2        /* Permission to keyup the transmitter */
  70. #define KEYWT        3        /* Transmitter switched on, waiting for CTS */
  71. #define ACTIVE        4        /* Transmitter on, sending data */
  72. #define FLUSH        5        /* CRC sent - attempt to start next frame */
  73. #define TAIL        6        /* End of transmission, send tail */
  74.  
  75. #define MAXPARAMS    10
  76.  
  77.     int params[11]; /* Channel control parameters */
  78. #define TXDELAY        1        /* Transmit Delay 10 ms/cnt */
  79. #define PERSIST        2        /* Persistence (0-255) as a % */
  80. #define SLOTTIME    3        /* Delay to wait on persistence hit */
  81. #define TAILTIME    4        /* Delay after XMTR OFF */
  82. #define FULLDUP        5        /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
  83. #define TNCSPECIF    6        /* reserved for KISS-TNC-specific parameters */
  84. #define WAITTIME    7        /* Waittime before any transmit attempt */
  85. #define MAXKEYUP    8        /* Maximum time to transmit (seconds) */
  86. #define MINTIME        9        /* Minimal offtime after MAXKEYUP timeout */
  87. #define IDLETIME    10        /* Maximum idle time in ALWAYS KEYED mode (seconds) */
  88. };
  89.  
  90. /* SCC channel structure. one is allocated for each attached SCC channel, */
  91. /* so 2 of these are allocated for each fully utilized SCC chip */
  92. struct sccchan {
  93.     /* interrupt handlers for 4 different IP's */
  94.     /* MUST BE first 4 elements of this structure, and MUST remain */
  95.     /* in the sequence Transmit-Status-Receive-Special */
  96.     void (*int_transmit)(); /* Transmit Buffer Empty interrupt handler */
  97.     void (*int_extstat)();    /* External/Status Change interrupt handler */
  98.     void (*int_receive)();    /* Receive Character Avail. interrupt handler */
  99.     void (*int_special)();    /* Special Receive Condition interrupt handler */
  100.  
  101.     /* don't insert anything before "ctrl" (see assembly interrupt handler) */
  102.     ioaddr ctrl;            /* I/O address of CONTROL register */
  103.     ioaddr data;            /* I/O address of DATA register for this channel */
  104.  
  105.     unsigned char wreg[16]; /* Copy of last written value in WRx */
  106.     unsigned char status;    /* Copy of R0 at last external interrupt */
  107.     unsigned char txchar;    /* Char to transmit on next TX interrupt */
  108.  
  109.     struct fifo fifo;
  110.     struct scca a;            /* control structure for AX.25 use */
  111.  
  112.     struct mbuf *rbp;        /* Head of mbuf chain being filled */
  113.     struct mbuf *rbp1;        /* Pointer to mbuf currently being written */
  114.     struct mbuf *sndq;        /* Encapsulated packets awaiting transmission */
  115.     struct mbuf *tbp;        /* Transmit mbuf being sent */
  116.  
  117.     struct iface *iface;    /* associated interface structure */
  118.  
  119.     int bufsiz;
  120.  
  121.     int32 timercount;
  122.  
  123.     int group;                /* group ID for AX.25 TX interlocking */
  124. #define NOGROUP        0        /* not member of any group */
  125. #define RXGROUP        0x100    /* if set, only tx when all channels clear */
  126. #define TXGROUP        0x200    /* if set, don't transmit simultaneously */
  127.  
  128.     long speed;                /* Line speed, bps */
  129.     char extclock;            /* External clock source on RTxC/TRxC */
  130.     char fulldup;            /* External divider for fulldup available */
  131.     char tx_inhibit;        /* Transmit is not allowed when set */
  132.     char dum;                /* filler (keep addr even for speed) */
  133.  
  134.     /* statistic information on this channel */
  135.     long rxints;            /* Receiver interrupts */
  136.     long txints;            /* Transmitter interrupts */
  137.     long exints;            /* External/status interrupts */
  138.     long spints;            /* Special receiver interrupts */
  139.  
  140.     long enqueued;            /* Packets actually forwarded */
  141.     long rxframes;            /* Number of Frames Actally Received */
  142.     long rxerrs;            /* CRC Errors or KISS errors */
  143.     unsigned int nospace;    /* "Out of buffers" */
  144.     unsigned int rovers;    /* Receiver Overruns */
  145. };
  146. extern struct sccchan *sccchan[];
  147. #define NULLCHAN    (struct sccchan *)0
  148.  
  149. /* Z8530 SCC Register access macros */
  150.  
  151. #define rd(scc,reg)    RDSCC((scc)->ctrl,(reg))
  152. #define wr(scc,reg,val) WRSCC((scc)->ctrl,(reg),((scc)->wreg[reg] = val))
  153. #define or(scc,reg,val) WRSCC((scc)->ctrl,(reg),((scc)->wreg[reg] |= val))
  154. #define cl(scc,reg,val) WRSCC((scc)->ctrl,(reg),((scc)->wreg[reg] &= ~(val)))
  155.  
  156. #endif /* _SCC_H */